class Node(object):
    def __init__(self, val=None, children=None):
        self.val = val
        self.children = children

class Solution(object):
    def maxDepth(self, root):
        """
        :type root: Node
        :rtype: int
        """
        if not root:
            return 0
        index = 0
        now_stack = [root]
        while now_stack:
            index += 1
            next_stack = []
            for node in now_stack:
                if node.children:
                    next_stack += node.children
            now_stack = next_stack
        return index
